//
//  HttpTools.swift
//  News
//
//  Created by qiupeng on 2017/6/3.
//  Copyright © 2017年 Speedy. All rights reserved.
//

import UIKit
import Alamofire

enum MethodType {
    case get
    case post
}

class HttpTools {

    class func requestData(URLString:String, type: MethodType, parameters:[String : Any]? = nil, finishedCallback : @escaping (_ result: Any) -> ()) {
        
        
        let method = type == .get ? HTTPMethod.get : HTTPMethod.post
        
        Alamofire.request(URLString, method: method, parameters: parameters).responseJSON { (response) in
            
            guard let result = response.result.value else{
                return
            }
            
            finishedCallback(result)
        }
        
        
    }
}
